package model.core.code;

public class VarEntrance extends IEntrance {
	protected IEntrance type;
	
	public VarEntrance(String entName, IEntrance type) {
		super(entName);
		this.type = type;
	}
	
	public IEntrance getTypeEntrance() {
		return type;
	}

	@Override
	public boolean equals(Object o) {
		if(o instanceof VarEntrance) {
			VarEntrance varEntr = (VarEntrance)o;
			if(type != null) {
				return super.equals(varEntr) && type.equals(varEntr.type);
			} else {
				return super.equals(varEntr) && type == varEntr.type;
			}
		}
		return false;
	}
	
	@Override
	public int hashCode() {
		if(type == null)
			return super.hashCode();
		else
			return type.hashCode() + super.hashCode();
	}

	@Override
	public EntranceType getEntranceType() {
		return EntranceType.VAR;
	}
}
